package unit7;

import java.util.ArrayList;
import java.util.List;

public class Rw7_1 {
    public static void main(String[] args) {
        List<Student> ss = new ArrayList<Student>();
        ss.add(new Student("001", "张三", "男", 20));
        ss.add(new Student("002", "李四", "男", 19));
        ss.add(new Student("003", "王五", "女", 22));
        System.out.println("初始化");
        System.out.println(ss);

        System.out.println("\n插入");
        ss.add(2, new Student("005", "赵六", "男", 23));
        System.out.println(ss);

        System.out.println("\n修改");
        ss.set(2, new Student("006", "赵六六", "男", 23));
        System.out.println(ss);

        System.out.println("\n删除");
        Student s = ss.remove(2);
        System.out.println("删除: " + s);
        System.out.println(ss);

    }
}

class Student {
    String no;
    String name;
    String sex;
    int age;

    public Student(String no, String name, String sex, int age) {
        this.no = no;
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

    @Override
    public String toString() {
        return "\nStudent{" +
                "no='" + no + '\'' +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                '}';
    }
}